home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / intrvews / xgrab.lha / xgrab / ui / getinp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-25  |  1.2 KB  |  67 lines

  1. /**
  2.    GRAB Graph Layout and Browser System
  3.  
  4.    Copyright (c) 1986, 1988 Regents of the University of California
  5.    Copyright (c) 1989, Tera Computer Company
  6.  **/
  7.  
  8. /* getinp.c - routines to get text input from user.  using a dialogbox */
  9.  
  10. #include <stdio.h>
  11. #include <sgtty.h>
  12. #include <ctype.h>
  13. #include <string.h>
  14.  
  15. #include "digraph.h"
  16. #include "globals.h"
  17. #include "interf.h"
  18. #include "cursor.h"
  19.  
  20. int (*endproc)();
  21.  
  22.   /**
  23.      Call TakeTextInput with the name of a procedure to call when
  24.      the text is taken.
  25.  
  26.      This endProc business seems a little silly, but that's the way
  27.      it was originally and I didn't bother changing things
  28.  
  29.      Invariably, endProc will want to call OutofText to get the result
  30.    **/
  31.  
  32. TakeTextInput(endProc)
  33. int (*endProc)();
  34. {
  35.     endproc = endProc;
  36.     ISetCursor(textC);
  37.     IntoText();
  38.     IUnsetCursor();
  39.     (*endProc)();
  40. }
  41.  
  42. #define TEXT_BUF_MAX    40        /* length of input line */
  43. char text_buf[TEXT_BUF_MAX+1];
  44.  
  45. OutofText(str)
  46. char *str;
  47.   /**
  48.      str should be at least TEXT_BUF_MAX + 1 characters long 
  49.    **/
  50. {
  51.     strcpy(str, text_buf);
  52. }
  53.  
  54. IntoText()
  55. {
  56.     char *s;
  57.  
  58.     if ((s = IGetText()) == NULL)
  59.     {
  60.     strcpy (text_buf, NULL_STRING);
  61.     }
  62.     else
  63.     {
  64.         strncpy (text_buf, s, TEXT_BUF_MAX);
  65.     }
  66. }
  67.